package logic

import (
	"context"
	"wxapi/internal/services"

	"wxapi/internal/svc"
	"wxapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetAreaListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetAreaListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAreaListLogic {
	return &GetAreaListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetAreaListLogic) GetAreaList(req *types.GetAreaListReq) (resp *types.GetAreaListResp, err error) {
	areas, err := services.GetStoreExistsArea(l.ctx, l.svcCtx, req.Province, req.City)
	if err != nil {
		return nil, err
	}

	resp = &types.GetAreaListResp{
		List: areas,
	}

	return
}
